﻿using ModelDataInitializerSeed.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace ModelDataInitializerSeed.Models
{
    /// <summary>
    /// System.Data.Entity.DropCreateDatabaseAlways<MusicStoreDB>
    /// 系统   数据  实体  方法
    /// DropCreateDatabaseAlways
    /// 如果你想在每次运行时都重新生成数据库就用这个方法
    /// </summary>
    public class MusicStoreDblnitializer:System.Data.Entity.CreateDatabaseIfNotExists<MusicStoreDB>
    {
        /// <summary>
        /// 受保护的可覆盖的无效种子
        /// </summary>
        /// <param name="context">数据库上下文的对象,有model文件的所有数据字段属性</param>
        protected override void Seed(MusicStoreDB context)
        {
            context.Artists.Add(new Artist { Name = "Al Di Meol" });
            context.Genres.Add(new Genre { Name = "Jazz" });
            context.Albums.Add(new Album
            {
                Genre = new Genre { Name = "Rock" },
                Artist=new Artist { Name= "Rush" },
                Price=9.99m,
                Title="Caravan"
            });

            base.Seed(context);
        }
    }
}